package com.java110.mall.shop.cmd.shop;

import com.alibaba.fastjson.JSONObject;
import com.java110.core.annotation.Java110Cmd;
import com.java110.core.context.CmdContextUtils;
import com.java110.core.context.Environment;
import com.java110.core.context.ICmdDataFlowContext;
import com.java110.core.event.cmd.Cmd;
import com.java110.core.event.cmd.CmdEvent;
import com.java110.mall.shop.bmo.shop.IUpdateShopBMO;
import com.java110.utils.exception.CmdException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;

@Java110Cmd(serviceCode = "shop.auditShopCommunity")
public class AuditShopCommunityCmd extends Cmd {

    @Autowired
    private IUpdateShopBMO updateShopBMOImpl;

    @Override
    public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException {
        Environment.isDevEnv();
    }

    @Override
    public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException {
        String userId = CmdContextUtils.getUserId(context);
        reqJson.put("userId", userId);
        ResponseEntity<String> responseEntity = updateShopBMOImpl.auditShopCommunity(reqJson);
        context.setResponseEntity(responseEntity);
    }
}
